<?php
/**
 * Created by PhpStorm.
 * User: fuguang
 * Date: 2017/6/12
 * Time: 下午6:51
 */

namespace backend\models;


use yii\base\Model;
use Yii;

class BaseModel extends Model
{

    public static function permission( $url ){
        $route = explode("/",$url);

        //权限控制
        $ctl = $route['1'];
        $actionname = $route['2'];

        $actionPath =  strtolower("/{$ctl}/{$actionname}");//具体action
        $controllerPath = strtolower("／{$ctl}/*");//controller
        $sitePath = "／*";//整站

        if(Yii::$app->user->can($sitePath) || Yii::$app->user->can($controllerPath) || Yii::$app->user->can($actionPath)){
            return true;
        }
        return false;
    }
}